from mediator import mediator
from mediator . tests . test_assistant import make_mediator_test_keyword_args

class browser_gui_fake :
    def __init__ ( self ) :
        self . _hide_browser = False
        self . _add_title_label_to_browser = None
        self . _add_table_to_browser = False
        self . _add_action_button_to_browser = None
        self . _add_return_button_to_browser = False
        self . _add_title_row_to_browser = None
        self . _add_existing_row_to_browser = None
        self . _add_empty_row_to_browser = False
        self . _add_action_row_to_browser = False
        self . _focus_entry_in_browser = False
        self . _unfocus_entry_in_browser = False
        self . _set_entry_text_in_browser = None
        self . _set_title_text_in_browser = None
        self . _application_window_reply = None
        self . _gui_create_frame_reply = None
        self . _gui_create_label_reply = None
        self . _gui_create_button_reply = None
        self . _gui_entry_text_reply = None
        self . _gui_focus_in_event_reply = None
        self . _gui_focus_out_event_reply = None
        self . _add_table_entry_reply = None
        self . _entry_text_in_browser_request = False
    def application_window_reply ( self , window ) :
        self . _application_window_reply = window
    def gui_create_frame_reply ( self , frame ) :
        self . _gui_create_frame_reply = frame
    def gui_create_label_reply ( self , label ) :
        self . _gui_create_label_reply = label
    def gui_create_button_reply ( self , button ) :
        self . _gui_create_button_reply = button
    def gui_entry_text_reply ( self , text ) :
        self . _gui_entry_text_reply = text
    def gui_focus_in_event_reply ( self , event ) :
        self . _gui_focus_in_event_reply = event
    def gui_focus_out_event_reply ( self , event ) :
        self . _gui_focus_out_event_reply = event
    def add_table_entry_reply ( self , entry ) :
        self . _add_table_entry_reply = entry
    def entry_text_in_browser_request ( self ) :
        self . _entry_text_in_browser_request = True
    def show_browser ( self ) :
        mediator_browser_gui_tests . _call_history += [ browser_gui_fake . show_browser ]
    def hide_browser ( self ) :
        self . _hide_browser = True
    def add_title_label_to_browser ( self , title_text ) :
        self . _add_title_label_to_browser = title_text
    def add_table_to_browser ( self ) :
        self . _add_table_to_browser = True
    def add_action_button_to_browser ( self , action_text ) :
        self . _add_action_button_to_browser = action_text
    def add_return_button_to_browser ( self ) :
        self . _add_return_button_to_browser = True
    def add_title_row_to_browser ( self , number , name , creation_time , modification_time , size ) :
        self . _add_title_row_to_browser = [ number , name , creation_time , modification_time , size ]
    def add_existing_row_to_browser ( self , number , name , creation_time , modification_time , size ) :
        self . _add_existing_row_to_browser = [ number , name , creation_time , modification_time , size ]
    def add_empty_row_to_browser ( self ) :
        self . _add_empty_row_to_browser = True
    def add_action_row_to_browser ( self ) :
        self . _add_action_row_to_browser = True
    def focus_entry_in_browser ( self ) :
        self . _focus_entry_in_browser = True
    def unfocus_entry_in_browser ( self ) :
        self . _unfocus_entry_in_browser = True
    def set_entry_text_in_browser ( self , text ) :
        self . _set_entry_text_in_browser = text
    def set_title_text_in_browser ( self , text ) :
        self . _set_title_text_in_browser = text

class arbitrary_module_fake :
    def show_browser ( self ) :
        mediator_browser_gui_tests . _call_history += [ arbitrary_module_fake . show_browser ]
    def hide_browser ( self ) :
        pass
    def application_window_reply ( self , window ) :
        pass
    def gui_create_frame_reply ( self , frame ) :
        pass
    def gui_create_label_reply ( self , label ) :
        pass
    def gui_create_button_reply ( self , button ) :
        pass
    def gui_entry_text_reply ( self , text ) :
        pass

class mediator_browser_gui_tests : 
    'mediator_browser_gui'
    def __init__ ( self , test ) :
        mediator_browser_gui_tests . _call_history = [ ]
        self . _test = test
        self . _browser_gui = browser_gui_fake ( )
        self . _mediator = mediator ( )
        self . _mediator . register_modules ( ** make_mediator_test_keyword_args \
            ( 'browser_gui' 
            , self . _browser_gui 
            , arbitrary_module_fake
            ) )
    def test_show_browser_called_first ( self ) :
        self . _mediator . show_browser ( )
        self . _test . assume_equal ( mediator_browser_gui_tests . _call_history [ 0 ] , browser_gui_fake . show_browser )
    def test_hide_browser ( self ) :
        self . _mediator . hide_browser ( )
        self . _test . assume_true ( self . _browser_gui . _hide_browser )
    def test_add_title_row_to_browser ( self ) :
        self . _mediator . add_title_row_to_browser \
            ( 'my number'
            , 'my name'
            , 'my creation time'
            , 'my modification time'
            , 'my size'
            )
        self . _test . assume_equal ( self . _browser_gui . _add_title_row_to_browser ,
            [ 'my number'
            , 'my name'
            , 'my creation time'
            , 'my modification time'
            , 'my size'
            ] )
    def test_add_existing_row_to_browser ( self ) :
        self . _mediator . add_existing_row_to_browser \
            ( 'my number'
            , 'my name'
            , 'my creation time'
            , 'my modification time'
            , 'my size'
            )
        self . _test . assume_equal ( self . _browser_gui . _add_existing_row_to_browser ,
            [ 'my number'
            , 'my name'
            , 'my creation time'
            , 'my modification time'
            , 'my size'
            ] )
    def test_add_empty_row_to_browser ( self ) :
        self . _mediator . add_empty_row_to_browser ( )
        self . _test . assume_true ( self . _browser_gui . _add_empty_row_to_browser )
    def test_add_action_row_to_browser ( self ) :
        self . _mediator . add_action_row_to_browser ( )
        self . _test . assume_true ( self . _browser_gui . _add_action_row_to_browser )
    def test_focus_entry_in_browser ( self ) :
        self . _mediator . focus_entry_in_browser ( )
        self . _test . assume_true ( self . _browser_gui . _focus_entry_in_browser )
    def test_unfocus_entry_in_browser ( self ) :
        self . _mediator . unfocus_entry_in_browser ( )
        self . _test . assume_true ( self . _browser_gui . _unfocus_entry_in_browser )
    def test_entry_text_in_browser_request ( self ) :
        self . _mediator . entry_text_in_browser_request ( )
        self . _test . assume_true ( self . _browser_gui . _entry_text_in_browser_request )
    def test_set_entry_text_in_browser ( self ) :
        self . _mediator . set_entry_text_in_browser ( 'my text' )
        self . _test . assume_equal ( self . _browser_gui . _set_entry_text_in_browser , 'my text' )
    def test_set_title_text_in_browser ( self ) :
        self . _mediator . set_title_text_in_browser ( 'my text' )
        self . _test . assume_equal ( self . _browser_gui . _set_title_text_in_browser , 'my text' )
    def test_add_title_label_to_browser ( self ) :
        self . _mediator . add_title_label_to_browser ( 'my title' )
        self . _test . assume_equal ( self . _browser_gui . _add_title_label_to_browser , 'my title' )
    def test_add_table_to_browser ( self ) :
        self . _mediator . add_table_to_browser ( )
        self . _test . assume_true ( self . _browser_gui . _add_table_to_browser )
    def test_add_action_button_to_browser ( self ) :
        self . _mediator . add_action_button_to_browser ( 'my button' )
        self . _test . assume_equal ( self . _browser_gui . _add_action_button_to_browser , 'my button' )
    def test_add_return_button_to_browser ( self ) :
        self . _mediator . add_return_button_to_browser ( )
        self . _test . assume_true ( self . _browser_gui . _add_return_button_to_browser )
    def test_application_window_reply ( self ) :
        self . _mediator . application_window_reply ( 'my window' )
        self . _test . assume_equal ( self . _browser_gui . _application_window_reply , 'my window' )
    def test_gui_create_frame_reply ( self ) :
        self . _mediator . gui_create_frame_reply ( 'my frame' )
        self . _test . assume_equal ( self . _browser_gui . _gui_create_frame_reply , 'my frame' )
    def test_gui_create_label_reply ( self ) :
        self . _mediator . gui_create_label_reply ( 'my label' )
        self . _test . assume_equal ( self . _browser_gui . _gui_create_label_reply , 'my label' )
    def test_gui_create_button_reply ( self ) :
        self . _mediator . gui_create_button_reply ( 'my button' )
        self . _test . assume_equal ( self . _browser_gui . _gui_create_button_reply , 'my button' )
    def test_gui_entry_text_reply ( self ) :
        self . _mediator . gui_entry_text_reply ( 'my text' )
        self . _test . assume_equal ( self . _browser_gui . _gui_entry_text_reply , 'my text' )
    def test_gui_focus_in_event_reply ( self ) :
        self . _mediator . gui_focus_in_event_reply ( 'my focus in' )
        self . _test . assume_equal ( self . _browser_gui . _gui_focus_in_event_reply , 'my focus in' )
    def test_gui_focus_out_event_reply ( self ) :
        self . _mediator . gui_focus_out_event_reply ( 'my focus out' )
        self . _test . assume_equal ( self . _browser_gui . _gui_focus_out_event_reply , 'my focus out' )
    def test_add_table_entry_reply ( self ) :
        self . _mediator . add_table_entry_reply ( 'my entry' )
        self . _test . assume_equal ( self . _browser_gui . _add_table_entry_reply , 'my entry' )
